﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

// 僵尸管理器(每个战斗场景都有一个)
public class ZombieMgr
{
    // 可用的进攻线路，不可用的索引为null
    private List<AttackLine> _allLines;
    // 僵尸生产时间线
    private TimeLine _timeLine = new TimeLine();

    /// <summary>
    /// 
    /// </summary>
    /// <param name="allLines">可用的进攻线路，不可用的索引为null</param>
    public void Init(List<AttackLine> allLines)
    {
        _allLines = allLines;
        // 初始化僵尸生产规则(暂不支持“波次提前”)
        _timeLine.AddEvent(0.5f, new ZombieCreateInfo() { RowIndex = 0, ZID = 1}, createZombie);
        _timeLine.AddEvent(0.5f, new ZombieCreateInfo() { RowIndex = 1, ZID = 1 }, createZombie);
        _timeLine.AddEvent(0.5f, new ZombieCreateInfo() { RowIndex = 2, ZID = 1 }, createZombie);
        _timeLine.Start();
    }

    // 创建僵尸
    private void createZombie(object obj)
    {
        var zcInfo = obj as ZombieCreateInfo;

        // zcInfo.ZID;
        var aline = _allLines[zcInfo.RowIndex];

        ZombieInScene zombie = new ZombieInScene();
        zombie.Init(aline);
    }

    /// <summary>
    /// 生产僵尸需要的数据
    /// </summary>
    private class ZombieCreateInfo
    {
        public int RowIndex; // 第几行
        public int ZID; // 生成此类型的僵尸
    }
}

